import { FormInstance } from 'antd';
import { ObservableForm } from './observableForm';

const modelMap = new Map<string, any>();

export default function useObservableForm(
  name: string,
  form?: FormInstance,
): ObservableForm {
  let ele = modelMap.get(name);
  if (!ele) {
    ele = new ObservableForm(form!);
    modelMap.set(name, ele);
  }
  return ele;
}
